clear;

input_layer_size = 400;
hidden_layer_size = 25;
num_labels = 10;

load('ex3data1.mat');
m = size(X, 1);

sel = randperm(m);
displayData(X(sel(1:100), :));

load('ex3weights.mat');
pred = predict(Theta1, Theta2, X);
fprintf('\nTraining Set Accuracy: %f\n', mean(double(pred == y)) * 100);

rp = randperm(m);

for i = 1:m
    fprintf('\nDisplaying Example Image\n');
    displayData(X(rp(i), :));
    pred = predict(Theta1, Theta2, X(rp(i), :));
    fprintf('\nNeural Network Prediction: %d (digit %d)\n', pred, mod(pred, 10));
    s = input('Paused - press enter to continue, q to exit:', 's');

    if s == 'q'
        break
    end

end
